@model Cxuu.Models.EditPassWord
@{
    ViewData["Title"] = "修改密码";
}
<div class="content-top-nav">
    <div class="layui-row">
        <div class="layui-col-md11">
            <h3 style="color:#444">
                <i class="layui-icon layui-icon-home"></i>
                @ViewData["Title"]
            </h3>
        </div>
        <div class="layui-col-md1" style="text-align:right;">

        </div>
    </div>
    <hr>
</div>

<div class="layui-fluid" style="margin-bottom:50px;">
    <div class="layui-form">
        <form class="layui-form" action="" lay-filter="FormEdit" enctype="multipart/form-data">
            <div class="layui-form-item">
                <label asp-for="Username" class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="text" asp-for="Username" disabled lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名" value="" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">用户不能自行修改登录名，如需修改，请联系系统管理员</div>
            </div>

            <div class="layui-form-item">
                <label asp-for="OldPassword" class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="text" asp-for="OldPassword" lay-verify="required" lay-reqtext="旧密码不能为空" placeholder="请输入密码" value="" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux"></div>
            </div>

            <div class="layui-form-item">
                <label asp-for="Password" class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="text" asp-for="Password" lay-verify="required" lay-reqtext="新密码不能为空" placeholder="请输入密码" value="" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">新密码为字母数字下划线及特殊字符组合,且最少6位最多20位！</div>
            </div>

            <div class="layui-form-item">
                <label asp-for="Nickname" class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="text" asp-for="Nickname" lay-verify="required" lay-reqtext="昵称不能为空" placeholder="请输入昵称" value="" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="saveBtn">修改</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>

     layui.use(['form', 'table', 'upload', 'jquery'], function () {
        var form = layui.form, layer = layui.layer, $ = layui.jquery;

        form.render();

        var editId = @ViewBag.id+1;
        //console.log(editId);
         if (editId > 1) {
             $.getJSON("/Admin/User/PassWord?&json=1", function (res) {
                 if (res.status == 1) {
                     form.val('FormEdit', {
                         //Id: res.data.id,
                         //Gid: res.data.gid,
                         Username: res.data.username,
                         //Password: res.data.password,
                         Nickname: res.data.nickname,
                         //Status: res.data.status,
                     });
                 } else {
                     layer.msg("数据错误！", { icon: 2, anim: 6, time: 5000 });
                 }

             })
         } else {
             layer.msg("用户错误！", { icon: 2, anim: 6, time: 5000 });
         }

        var dataPost = function (url,data) {
            $.post(url, data, function (res) {
                if (res.status == 1) {
                    layer.msg(res.msg, { icon: 1, time: 1000 }, function () {
                        location.href = '/Admin/Login/LoginOut';
                    });
                } else {
                    layer.msg(res.msg, { icon: 2, anim: 6, time: 5000 });
                }
            });
        }

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var editPass = {
                //Gid: data.field.Gid,
                //Username: data.field.Username,
                Nickname: data.field.Nickname,
                Password: data.field.Password,
                OldPassword: data.field.OldPassword,
                //Status: data.field.Status,
            };
            dataPost('/Admin/User/PassWord?edit=1', editPass);
            return false;
        });


    });
</script>